//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef CUSTOMAPPLAYER_H_
#define CUSTOMAPPLAYER_H_

#include "MiXiMDefs.h"
#include <MyTestAppLayer.h>

class MIXIM_API CustomAppLayer: public MyTestAppLayer {
private:
    //Number of sent packages
    long numSent;
    //Number of received packages
    long numReceived;
    //Consecutive Package ID
    int packageID;
    //Number of received broadcast packages
    long numReceivedBroadcast;

    //Signal to emmit sent values
    simsignal_t sentSignal;

    //Signal to emmit received values --> only for the central node
    simsignal_t receivedSignal;

    //Signal to emmit position x of the module
    simsignal_t positionXSignal;

    //Signal to emmit position y of the module
    simsignal_t positionYSignal;

    //Signal to emmit broadcast received
    simsignal_t receivedBroadcastSignal;


public:
    CustomAppLayer() :
        MyTestAppLayer(),burstSize(0),bSendReply(true)
    {

    }
    virtual ~CustomAppLayer()
    {

    }
    /** @brief Initialize module parameters*/
    virtual void initialize(int);

protected:
    /** @brief Handle self messages such as timer... */
    virtual void handleSelfMsg(cMessage*);

    /** @brief Handle messages from lower layer */
    virtual void handleLowerMsg(cMessage*);

    virtual double getModuleXPosition();

    virtual double getModuleYPosition();

    virtual double getModuleSpeed();


    virtual void updateDisplay();


    /** @brief Number of messages to send in a burst*/
    int burstSize;
    /** @brief If true, send a unicast BROADCAST_REPLY message to each
     * received BROADCAST message. */
    bool bSendReply;
};

#endif /* CUSTOMAPPLAYER_H_ */
